#/*************************************************************************
#    > File Name: examples/example_ARCH.py
#    > Author: Yan Wang
#    > Mail: wangyan@imnu.edu.cn
#    > Created Time: 2022年06月29日 星期三 23时28分59秒
# ************************************************************************/
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
sys.path.append('../Lib/')
from Load_Lib import * 



# Replace_Para_in_BASDA
origin_path_list={"process":"PROCESS          : sigh_w4b_$fnum",
					"tmp" :"RECORD_FILE      : 'tmp/sigh_w4b_$fnum.dat'",
					"file":"INPUT_FILE       : 'file_$fnum.dat'"}
origin_file_list={"file":"FILE            : [\"./examples/test_input/input_events/tag_1_delphes_events_$fnum.root\"]",
					"cross":"CROSS_SECTION   : $fvalue"}
origin_xection_list={"file":"        ./examples/test_input/sigh_w4b_$fnum.root        : $fvalue "}
input_para={"path":origin_path_list, 
			"file":origin_file_list,
			"xection":origin_xection_list}
cut_cross=[19.53, 66.25, 17.97, 0.6, 19.43]
results=Exhibit_Function(Replace_Para_in_BASDA,[input_para, cut_cross])


# Generate_Multi_BASDA_Control_File 
cut_cross=[19.53, 66.25, 17.97, 0.6, 19.43]

source = './examples/test_input/control_BASDA'
target = './examples/test_output/control_scan_BASDA_test'
dir_name={"source":source,"target":target}


para_path={"origin":{"process":"PROCESS                   : 10_bp3_4b0j_$fnum",
		          "out" :"OUTPUT_FOLDER             : \"events/Event_scan_$fnum\"",
				  "tmp" :"RECORD_FILE               : \"tmp/tmp_h_w4b_$fnum.dat\"",
				  "file":"INPUT_FILE                : \"file_$fnum.dat\""},
			"source":"path.dat",
			"labels":{"PROCESS                   : 10_bp3_4b0j_1":0,
				      "OUTPUT_FOLDER             : 'events/Event_scan_1'":0,
					  "RECORD_FILE               : 'tmp/tmp_h_w4b_1.dat'":0, 
					  "INPUT_FILE                : 'file_1.dat'":0}
			}
para_file={"origin":{"file":"FILE_0            : xsection_$fnum.dat"},
			"source":"file.dat",
			"labels":{"FILE_0            : xsection_1.dat":0}
			}
para_xection={"origin":{"file":"        ./examples/test_input/sigh_w4b_$fnum.root        : $fvalue"},
			"source":"xsection.dat",
			"labels":{"        file  : 1.554":0}
			}
input_para={"path":para_path, 
			"file":para_file,
			"xection":para_xection}
Exhibit_Function(Generate_Multi_BASDA_Control_File,[cut_cross, dir_name, input_para])


# Find_BASDA_xection 
BASDA_out_name="./examples/test_input/BASDA_output/Event_scan_{}/data/125/output_table_combined_125.dat"
total_file_num=3
Exhibit_Function(Find_BASDA_OutputTable, [BASDA_out_name,total_file_num])



